package eam

import org.codehaus.groovy.ast.GroovyCodeVisitor
import org.codehaus.groovy.ast.expr.*
import org.codehaus.groovy.ast.stmt.*
import org.codehaus.groovy.classgen.BytecodeExpression

/**
 * Created by Misty on 2015/6/6.
 */
class EAMGroovyCodeVisitor implements GroovyCodeVisitor {
    private static void visit(Statement statement) {
        println "\t${statement.text}                        // ${statement.class.simpleName}"

    }

    private static void visit(Expression expression) {
        println "\t${expression.text}                        // ${expression.class.simpleName}"

    }

    @Override
    void visitBlockStatement(BlockStatement statement) {
        statement.statements.each { it.visit(this) }
    }

    @Override
    void visitForLoop(ForStatement forLoop) {
        visit(forLoop)
    }

    @Override
    void visitWhileLoop(WhileStatement loop) {
        visit(loop)
    }

    @Override
    void visitDoWhileLoop(DoWhileStatement loop) {
        visit(loop)
    }

    @Override
    void visitIfElse(IfStatement ifElse) {
        visit(ifElse)
    }

    @Override
    void visitExpressionStatement(ExpressionStatement statement) {
        statement.expression.visit(this)
    }

    @Override
    void visitReturnStatement(ReturnStatement statement) {
        visit(statement)
    }

    @Override
    void visitAssertStatement(AssertStatement statement) {
        visit(statement)
    }

    @Override
    void visitTryCatchFinally(TryCatchStatement finally1) {
        visit(finally1)
    }

    @Override
    void visitSwitch(SwitchStatement statement) {
        visit(statement)
    }

    @Override
    void visitCaseStatement(CaseStatement statement) {
        visit(statement)
    }

    @Override
    void visitBreakStatement(BreakStatement statement) {
        visit(statement)
    }

    @Override
    void visitContinueStatement(ContinueStatement statement) {
        visit(statement)
    }

    @Override
    void visitThrowStatement(ThrowStatement statement) {
        visit(statement)
    }

    @Override
    void visitSynchronizedStatement(SynchronizedStatement statement) {
        visit(statement)
    }

    @Override
    void visitCatchStatement(CatchStatement statement) {
        visit(statement)
    }

    @Override
    void visitMethodCallExpression(MethodCallExpression call) {
        visit(call)
    }

    @Override
    void visitStaticMethodCallExpression(StaticMethodCallExpression expression) {
        visit(expression)
    }

    @Override
    void visitConstructorCallExpression(ConstructorCallExpression expression) {
        visit(expression)
    }

    @Override
    void visitTernaryExpression(TernaryExpression expression) {
        visit(expression)
    }

    @Override
    void visitShortTernaryExpression(ElvisOperatorExpression expression) {
        visit(expression)
    }

    @Override
    void visitBinaryExpression(BinaryExpression expression) {
        visit(expression)
    }

    @Override
    void visitPrefixExpression(PrefixExpression expression) {
        visit(expression)
    }

    @Override
    void visitPostfixExpression(PostfixExpression expression) {
        visit(expression)
    }

    @Override
    void visitBooleanExpression(BooleanExpression expression) {
        visit(expression)
    }

    @Override
    void visitClosureExpression(ClosureExpression expression) {
        visit(expression)
    }

    @Override
    void visitTupleExpression(TupleExpression expression) {
        visit(expression)
    }

    @Override
    void visitMapExpression(MapExpression expression) {
        visit(expression)
    }

    @Override
    void visitMapEntryExpression(MapEntryExpression expression) {
        visit(expression)
    }

    @Override
    void visitListExpression(ListExpression expression) {
        visit(expression)
    }

    @Override
    void visitRangeExpression(RangeExpression expression) {
        visit(expression)
    }

    @Override
    void visitPropertyExpression(PropertyExpression expression) {
        visit(expression)
    }

    @Override
    void visitAttributeExpression(AttributeExpression attributeExpression) {
        visit(attributeExpression)
    }

    @Override
    void visitFieldExpression(FieldExpression expression) {
        visit(expression)
    }

    @Override
    void visitMethodPointerExpression(MethodPointerExpression expression) {
        visit(expression)
    }

    @Override
    void visitConstantExpression(ConstantExpression expression) {
        visit(expression)
    }

    @Override
    void visitClassExpression(ClassExpression expression) {
        visit(expression)
    }

    @Override
    void visitVariableExpression(VariableExpression expression) {
        visit(expression)
    }

    @Override
    void visitDeclarationExpression(DeclarationExpression expression) {
        visit(expression)
    }

    @Override
    void visitGStringExpression(GStringExpression expression) {
        visit(expression)
    }

    @Override
    void visitArrayExpression(ArrayExpression expression) {
        visit(expression)
    }

    @Override
    void visitSpreadExpression(SpreadExpression expression) {
        visit(expression)
    }

    @Override
    void visitSpreadMapExpression(SpreadMapExpression expression) {
        visit(expression)
    }

    @Override
    void visitNotExpression(NotExpression expression) {
        visit(expression)
    }

    @Override
    void visitUnaryMinusExpression(UnaryMinusExpression expression) {
        visit(expression)
    }

    @Override
    void visitUnaryPlusExpression(UnaryPlusExpression expression) {
        visit(expression)
    }

    @Override
    void visitBitwiseNegationExpression(BitwiseNegationExpression expression) {
        visit(expression)
    }

    @Override
    void visitCastExpression(CastExpression expression) {
        visit(expression)
    }

    @Override
    void visitArgumentlistExpression(ArgumentListExpression expression) {
        visit(expression)
    }

    @Override
    void visitClosureListExpression(ClosureListExpression closureListExpression) {
        visit(closureListExpression)
    }

    @Override
    void visitBytecodeExpression(BytecodeExpression expression) {
        visit(expression)
    }
}
